import sys
import simpleweb

def help(name, args, parser):
    option, args = parser.parse_args()
    if len(args) < 1:
        print "usage: simpleweb-admin [ -h ] [ command [ -h | --help ] ]"
        print 

        print "commands:"
        try:
            plugins = __import__('simpleweb.admin.plugins', {}, {}, 'plugins')
        except ImportError, e:
            simpleweb.utils.msg_err("Failed to import simpleweb.admin.plugins: %s" % (e))
            sys.exit()
        else:
            plugins.__all__.append('help')
            plugins.__all__.sort()
            for i in plugins.__all__:
                print "  %s" % (i.replace('_', '-'))
